# https://gitee.com/yueyinqiu5990/tj12413601/blob/master/assignment1/question5/main_calculation_on_sin_bad.py
#
# 这里明显没能还原出 sin 函数，
# 见 main_calculation_on_sin_good.py 。
#
import math

import matplotlib.pyplot
import torch

import main_calculation

order = 100

period = 2 * math.pi
limit3 = period / 2
limit1 = -limit3
x_tensor = torch.linspace(limit1, limit3, order)
y_tensor = torch.tensor([math.sin(float(x)) for x in x_tensor])
result = torch.fft.fft(y_tensor)
d = {}
for i, f in enumerate(result):
    d[i] = complex(f) / order

matplotlib.pyplot.axvspan(-math.pi, math.pi, alpha=0.1)
# noinspection PyProtectedMember
main_calculation._draw_from_dictionary_of_a(d, p=2 * math.pi)
matplotlib.pyplot.show()
